package thread;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class TCPClient {
    public static void main(String args[]) throws Exception {
        BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
        Socket clientSocket=new Socket("localhost",9999);//Buoc 1
        DataOutputStream outToServer=new DataOutputStream(clientSocket.getOutputStream());
        BufferedReader inFromServer=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
        System.out.print("Nhap vao chuoi gui cho server: ");
        String gui=inFromUser.readLine();//buoc 3
        outToServer.writeBytes(gui+'\n');
        String nhan=inFromServer.readLine();
        System.out.println("Tu server: "+nhan);
        clientSocket.close();//buoc 5
    }
}
//Ve nha: xay dung chuong trinh S_C chay trong luong (nam trong phuong thuc Run)